   window["MzBrowser"]={};  
   (function()  
   {  
       if(MzBrowser.platform) return;  
       var ua = window.navigator.userAgent;  
       MzBrowser.platform = window.navigator.platform;  
     
       MzBrowser.firefox = ua.indexOf("Firefox")>0;  
       MzBrowser.opera = typeof(window.opera)=="object";  
       MzBrowser.ie = !MzBrowser.opera && ua.indexOf("MSIE")>0;  
       MzBrowser.mozilla = window.navigator.product == "Gecko";  
       MzBrowser.netscape= window.navigator.vendor=="Netscape";  
       MzBrowser.safari= ua.indexOf("Safari")>-1;  
     
       if(MzBrowser.firefox) var re = /Firefox(\s|\/)(\d+(\.\d+)?)/;  
       else if(MzBrowser.ie) var re = /MSIE( )(\d+(\.\d+)?)/;  
       else if(MzBrowser.opera) var re = /Opera(\s|\/)(\d+(\.\d+)?)/;  
       else if(MzBrowser.netscape) var re = /Netscape(\s|\/)(\d+(\.\d+)?)/;  
       else if(MzBrowser.safari) var re = /Version(\/)(\d+(\.\d+)?)/;  
       else if(MzBrowser.mozilla) var re = /rv(\:)(\d+(\.\d+)?)/;  
     
       if("undefined"!=typeof(re)&&re.test(ua))  
       MzBrowser.version = parseFloat(RegExp.$2);  
       })();

	   function copyToClipBoard(){
			if(MzBrowser.ie){  
				var clipBoardContent="";
				clipBoardContent+=document.title;
				clipBoardContent+="\n";
				clipBoardContent+=this.location.href;
				window.clipboardData.setData("Text",clipBoardContent);
				alert("复制成功，请粘贴到你的QQ/MSN上推荐给你的好友");
			}else if(MzBrowser.firefox){
				alert('您的浏览器不支持复制链接功能，请直接用Ctrl+C复制链接地址');
			}
		}

		function userCollect(){
			var s_user_id = document.getElementById('s_user_id').value;
			var info_id = document.colletForm.info_id.value;
			document.getElementById("info_url").value = window.location.href;
			document.getElementById("cust_id").value = document.getElementById('s_cust_id').value;
			if(s_user_id==''){
				alert('请登录');
			}else{
				$.ajax({
					type: 'POST',
					url: '/templets/html/shop/jsp/Bycollect.jsp',
					data: 'info_id=' + info_id,
					success: function(msg){
						if( msg == 1){
							alert('请不要重复收藏！');
						}else{
							document.colletForm.user_id.value =	s_user_id;
							document.colletForm.submit();
							alert('收藏成功！');
						}
					}
				});
			}
		}



		function CollectThisCustomer(){
		   var user_id = document.getElementById('s_user_id').value;
		   document.collectComForm.info_id.value = document.collectComForm.info_cust_id.value;
		   var info_id = document.collectComForm.info_id.value;
		   if(user_id == ''){
			   alert('请登录');
		   }else {
				$.ajax({
					type: 'POST',
					url: '/templets/html/shop/jsp/Bycollect.jsp',
					data: 'info_id=' + info_id,
					success: function(msg){
						if( msg == 1){
							alert('请不要重复收藏！');
						}else{
							document.collectComForm.submit();
						}
					}
				});
		   }
		}

		function dealCollection(){
			var s_user_id = document.getElementById('s_user_id').value;
			if(s_user_id==''){
				document.getElementById('collbefore').style.display = 'none';
				document.getElementById('collafter').style.display = 'block';
			}else{
				document.getElementById('collbefore').style.display = 'block';
				document.getElementById('collafter').style.display = 'none';
			}
		}

		function setAttrdesc(num,allnum,attr_id,attr_value,checkid){
			for(var i=1;i<=allnum;i++){
				if(i==num){
					document.getElementById(attr_id+i).style.border='2px solid red';
					
				}else{
					document.getElementById(attr_id+i).style.border='1px solid #cecece';
				}
			}
			//----设置单个属性以判断是否选择 
			document.getElementById(checkid).value = 0;
			
			var attr_desc_para = document.getElementById('attr_desc_para').value;
			

			if(attr_desc_para==''){
				document.getElementById('attr_desc_para').value = attr_id+'|'+attr_value+",";				
			}else{
				var attrNew = '';
				var attrAray = attr_desc_para.split(',');
				if(attrAray.length > 0){
					for(var j=0;j<attrAray.length;j++){
						var attr_one = attrAray[j];
						if(attr_one!=''){
							if(attr_one.indexOf(attr_id) > -1){
								attrNew = attrNew.replace(attr_one,'');
							}else{
								attrNew += attr_one+',';
							}
						}
					}
					attrNew += ','+attr_id+'|'+attr_value+',';
				}
				document.getElementById('attr_desc_para').value = attrNew;
			}
			 
		}

function loginSkip(){
				alert("您还没有登录,请先登录.");
				window.location.href='/shop_signin.html?'+location.href
			}
var ImageZoom=function(image,viewer,options){this._initialize(image,viewer,options);this._initLoad();};ImageZoom.prototype={_initialize:function(image,viewer,options){this._image=$$(image);this._zoom=document.createElement("img");this._viewer=$$(viewer);this._viewerWidth=0;this._viewerHeight=0;this._preload=new Image();this._rect=null;this._repairLeft=0;this._repairTop=0;this._rangeWidth=0;this._rangeHeight=0;this._timer=null;this._loaded=false;this._substitute=false;var opt=this._setOptions(options);this._scale=opt.scale;this._max=opt.max;this._min=opt.min;this._originPic=opt.originPic;this._zoomPic=opt.zoomPic;this._rangeWidth=opt.rangeWidth;this._rangeHeight=opt.rangeHeight;this.delay=opt.delay;this.autoHide=opt.autoHide;this.mouse=opt.mouse;this.rate=opt.rate;this.onLoad=opt.onLoad;this.onStart=opt.onStart;this.onMove=opt.onMove;this.onEnd=opt.onEnd;var oThis=this,END=function(){oThis._end();};this._END=function(){oThis._timer=setTimeout(END,oThis.delay);};this._START=$$F.bindAsEventListener(this._start,this);this._MOVE=$$F.bindAsEventListener(this._move,this);this._MOUSE=$$F.bindAsEventListener(this._mouse,this);this._OUT=$$F.bindAsEventListener(function(e){if(!e.relatedTarget)this._END();},this);$$CE.fireEvent(this,"init");},_setOptions:function(options){this.options={scale:0,max:10,min:1.5,originPic:"",zoomPic:"",rangeWidth:0,rangeHeight:0,delay:20,autoHide:true,mouse:false,rate:.2,onLoad:$$.emptyFunction,onStart:$$.emptyFunction,onMove:$$.emptyFunction,onEnd:$$.emptyFunction};return $$.extend(this.options,options||{});},_initLoad:function(){var image=this._image,originPic=this._originPic,useOrigin=!this._zoomPic&&this._scale,loadImage=$$F.bind(useOrigin?this._loadOriginImage:this._loadImage,this);this.autoHide&&this._hide();if(originPic&&originPic!=image.src){image.onload=loadImage;image.src=originPic;}else if(image.src){if(!image.complete){image.onload=loadImage;}else{loadImage();}}else{return;}
if(!useOrigin){var preload=this._preload,zoomPic=this._zoomPic||image.src,loadPreload=$$F.bind(this._loadPreload,this);if(zoomPic!=preload.src){preload.onload=loadPreload;preload.src=zoomPic;}else{if(!preload.complete){preload.onload=loadPreload;}else{this._loadPreload();}}}},_loadOriginImage:function(){this._image.onload=null;this._zoom.src=this._image.src;this._initLoaded();},_loadImage:function(){this._image.onload=null;if(this._loaded){this._initLoaded();}else{this._loaded=true;if(this._scale){this._substitute=true;this._zoom.src=this._image.src;this._initLoaded();}}},_loadPreload:function(){this._preload.onload=null;this._zoom.src=this._preload.src;if(this._loaded){if(!this._substitute){this._initLoaded();}}else{this._loaded=true;}},_initLoaded:function(src){this._initSize();this._initViewer();this._initData();$$CE.fireEvent(this,"load");this.onLoad();this.start();},_initSize:function(){var zoom=this._zoom,image=this._image,scale=this._scale;if(!scale){scale=this._preload.width/image.width;}
this._scale=scale=Math.min(Math.max(this._min,scale),this._max);zoom.width=Math.ceil(image.width*scale);zoom.height=Math.ceil(image.height*scale);},_initViewer:function(){var zoom=this._zoom,viewer=this._viewer;var styles={padding:0,overflow:"hidden"},p=$$D.getStyle(viewer,"position");if(p!="relative"&&p!="absolute"){styles.position="relative";};$$D.setStyle(viewer,styles);zoom.style.position="absolute";if(!$$D.contains(viewer,zoom)){viewer.appendChild(zoom);}},_initData:function(){var zoom=this._zoom,image=this._image,viewer=this._viewer,scale=this._scale,rangeWidth=this._rangeWidth,rangeHeight=this._rangeHeight;this._rect=$$D.rect(image);this._repairLeft=image.clientLeft+parseInt($$D.getStyle(image,"padding-left"));this._repairTop=image.clientTop+parseInt($$D.getStyle(image,"padding-top"));if(rangeWidth>0&&rangeHeight>0){rangeWidth=Math.ceil(rangeWidth);rangeHeight=Math.ceil(rangeHeight);this._viewerWidth=Math.ceil(rangeWidth*scale);this._viewerHeight=Math.ceil(rangeHeight*scale);$$D.setStyle(viewer,{width:this._viewerWidth+"px",height:this._viewerHeight+"px"});}else{var styles;if(!viewer.clientWidth){var style=viewer.style;styles={display:style.display,position:style.position,visibility:style.visibility};$$D.setStyle(viewer,{display:"block",position:"absolute",visibility:"hidden"});}
this._viewerWidth=viewer.clientWidth;this._viewerHeight=viewer.clientHeight;if(styles){$$D.setStyle(viewer,styles);}
rangeWidth=Math.ceil(this._viewerWidth/scale);rangeHeight=Math.ceil(this._viewerHeight/scale);}
this._rangeWidth=rangeWidth;this._rangeHeight=rangeHeight;},_start:function(){clearTimeout(this._timer);var viewer=this._viewer,image=this._image,scale=this._scale;viewer.style.display="block";$$CE.fireEvent(this,"start");this.onStart();$$E.removeEvent(image,"mouseover",this._START);$$E.removeEvent(image,"mousemove",this._START);$$E.addEvent(document,"mousemove",this._MOVE);$$E.addEvent(document,"mouseout",this._OUT);this.mouse&&$$E.addEvent(document,$$B.firefox?"DOMMouseScroll":"mousewheel",this._MOUSE);},_move:function(e){clearTimeout(this._timer);var x=e.pageX,y=e.pageY,rect=this._rect;if(x<rect.left||x>rect.right||y<rect.top||y>rect.bottom){this._END();}else{var pos={},scale=this._scale,zoom=this._zoom,viewerWidth=this._viewerWidth,viewerHeight=this._viewerHeight;pos.left=viewerWidth/2-(x-rect.left-this._repairLeft)*scale;pos.top=viewerHeight/2-(y-rect.top-this._repairTop)*scale;$$CE.fireEvent(this,"repair",e,pos);x=Math.ceil(Math.min(Math.max(pos.left,viewerWidth-zoom.width),0));y=Math.ceil(Math.min(Math.max(pos.top,viewerHeight-zoom.height),0));zoom.style.left=x+"px";zoom.style.top=y+"px";$$CE.fireEvent(this,"move",e,x,y);this.onMove();}},_end:function(){$$CE.fireEvent(this,"end");this.onEnd();this.autoHide&&this._hide();this.stop();this.start();},_hide:function(){this._viewer.style.display="none";},_mouse:function(e){this._scale+=(e.wheelDelta?e.wheelDelta/(-120):(e.detail||0)/3)*this.rate;var opt=this.options;this._rangeWidth=opt.rangeWidth;this._rangeHeight=opt.rangeHeight;this._initSize();this._initData();this._move(e);e.preventDefault();},start:function(){if(this._viewerWidth&&this._viewerHeight){var image=this._image,START=this._START;$$E.addEvent(image,"mouseover",START);$$E.addEvent(image,"mousemove",START);}},stop:function(){clearTimeout(this._timer);$$E.removeEvent(this._image,"mouseover",this._START);$$E.removeEvent(this._image,"mousemove",this._START);$$E.removeEvent(document,"mousemove",this._MOVE);$$E.removeEvent(document,"mouseout",this._OUT);$$E.removeEvent(document,$$B.firefox?"DOMMouseScroll":"mousewheel",this._MOUSE);},reset:function(options){this.stop();var viewer=this._viewer,zoom=this._zoom;if($$D.contains(viewer,zoom)){viewer.removeChild(zoom);}
var opt=$$.extend(this.options,options||{});this._scale=opt.scale;this._max=opt.max;this._min=opt.min;this._originPic=opt.originPic;this._zoomPic=opt.zoomPic;this._rangeWidth=opt.rangeWidth;this._rangeHeight=opt.rangeHeight;this._loaded=this._substitute=false;this._rect=null;this._repairLeft=this._repairTop=this._viewerWidth=this._viewerHeight=0;this._initLoad();},dispose:function(){$$CE.fireEvent(this,"dispose");this.stop();if($$D.contains(this._viewer,this._zoom)){this._viewer.removeChild(this._zoom);}
this._image.onload=this._preload.onload=this._image=this._preload=this._zoom=this._viewer=this.onLoad=this.onStart=this.onMove=this.onEnd=this._START=this._MOVE=this._END=this._OUT=null}}
ImageZoom._MODE={"handle":{options:{handle:""},methods:{init:function(){var handle=$$(this.options.handle);if(!handle){var body=document.body;handle=body.insertBefore(this._viewer.cloneNode(false),body.childNodes[0]);handle.id="";handle["_createbyhandle"]=true;}else{var style=handle.style;this._stylesHandle={left:style.left,top:style.top,position:style.position,display:style.display,visibility:style.visibility,padding:style.padding,margin:style.margin,width:style.width,height:style.height};}
$$D.setStyle(handle,{padding:0,margin:0,display:"none"});this._handle=handle;this._repairHandleLeft=0;this._repairHandleTop=0;},load:function(){var handle=this._handle,rect=this._rect;$$D.setStyle(handle,{position:"absolute",width:this._rangeWidth+"px",height:this._rangeHeight+"px",display:"block",visibility:"hidden"});this._repairHandleLeft=rect.left+this._repairLeft-handle.clientLeft;this._repairHandleTop=rect.top+this._repairTop-handle.clientTop;if(!/BODY|HTML/.test(handle.offsetParent.nodeName)){var parent=handle.offsetParent,rect=$$D.rect(parent);this._repairHandleLeft-=rect.left+parent.clientLeft;this._repairHandleTop-=rect.top+parent.clientTop;}
$$D.setStyle(handle,{display:"none",visibility:"visible"});},start:function(){this._handle.style.display="block";},move:function(e,x,y){var style=this._handle.style,scale=this._scale;style.left=Math.ceil(this._repairHandleLeft-x/scale)+"px";style.top=Math.ceil(this._repairHandleTop-y/scale)+"px";},end:function(){this._handle.style.display="none";},dispose:function(){if("_createbyhandle"in this._handle){document.body.removeChild(this._handle);}else{$$D.setStyle(this._handle,this._stylesHandle);}
this._handle=null;}}}}
ImageZoom.prototype._initialize=(function(){var init=ImageZoom.prototype._initialize,mode=ImageZoom._MODE,modes={"follow":[mode.follow],"handle":[mode.handle],"cropper":[mode.cropper],"handle-cropper":[mode.handle,mode.cropper]};return function(){var options=arguments[2];if(options&&options.mode&&modes[options.mode]){$$A.forEach(modes[options.mode],function(mode){$$.extend(options,mode.options,false);$$A.forEach(mode.methods,function(method,name){$$CE.addEvent(this,name,method);},this);},this);}
init.apply(this,arguments);}})();

var imageTotal = 0;
			
function getPosition(E)
{  
    var t=e.offsetTop;  var l=e.offsetLeft;  
    while(e=e.offsetParent){t+=e.offsetTop+(isIE()?e.clientTop:0);l+=e.offsetLeft+(isIE()?e.clientLeft:0);}  
    var pos = {left:l,top:t};  
    pos[0]=l;pos[1]=t;  
    return pos;  
} 
function setGoodsImg(num)
{

	var goods = 'goodsimg'+num;
	var exp = document.getElementById('goodsimg'+num);
	if( !exp && typeof(exp)!="undefined" )
	{
	   var img = $$("goodsbigimgDiv").appendChild(document.createElement("img"));
	   img.src = "/templets/html/images/cpwu.gif";
	}
	else
	{
		var samllsrc = exp.src;
		var bigsrc = exp.src.replace('small','big');
		var p = $("#goodsbigimgDiv").position();
		var left = p.left + $("#goodsbigimgDiv").width()+20;
		var p_top = p.top;
		var g_div_height = $("#goodsbigimgDiv").height();
		var img_top = p_top +g_div_height;
		var init_top =  p_top+ 70;
		$("#idViewer2").css({"left":left+"px","top":init_top+"px"});
		$(window).scroll(function(){
		   var scoll_top = $(document).scrollTop();
		   var top =  70+ scoll_top;
		   if(scoll_top <= p_top){top=init_top;}
		   if(top >= img_top){top =img_top;}
		   $("#idViewer2").css({"left":left+"px","top":top+"px"});
		});
		$$("goodsbigimgDiv").innerHTML='';
		var img = $$("goodsbigimgDiv").appendChild(document.createElement("img"));
		img.src = samllsrc;
		img.id ="showImg";
	  //img.width = "400";
	  //img.height = "460";				
		var iz = new ImageZoom("showImg", "idViewer2", {
			mode: "handle", handle: "idHandle3", scale: 2, delay: 0
		});
		
		iz.reset({ originPic: samllsrc, zoomPic: bigsrc});
	}
}

	  
var imgpage = 1;
var pageNum = 5; //display image number per page
var start = 0,end = 0;//display imgage from start to end
showLittleImg(imgpage);

function showLittleImg(num){
	start = (num-1)*pageNum +1;
	end = num*pageNum;
	for(var i=start;i<=end;i++){
		disImgShow(i,'block');
	}
	for(var i=1;i<start;i++){
		disImgShow(i,'none');
	}
	for(var i=end+1;i<=10;i++){
		var exp = document.getElementById('goodsimg'+i);
		if( !exp && typeof(exp)!="undefined" ){
			imageTotal = i;
			break;
		}else{
			document.getElementById('goodsimg'+i).style.display = 'none';
		}
	}
	imageTotal = imageTotal-1;
	checkUDimg();
}

function disImgShow(i,dis){
	var exp = document.getElementById('goodsimg'+i);
	if( !exp && typeof(exp)!="undefined" ){
	}else{
		document.getElementById('goodsimg'+i).style.display = dis;
	}
}

function showDown(){
	imgpage += 1;
	showLittleImg(imgpage);
}

function showUp(){
	imgpage -= 1;
	showLittleImg(imgpage);
}

function checkUDimg(){
	if(start==1){
		document.getElementById('upHref').href='###';
		document.getElementById('upImg').src='/templets/html/shop/images/cont_l_t.jpg';
	}else{
		document.getElementById('upHref').href='javascript:showUp();';
		//document.getElementById('upImg').src='/templets/html/shop/images/cont_l_t_s.jpg';
	}
	if(end>=imageTotal){
		document.getElementById('downHref').href='###';
		document.getElementById('downImg').src='/templets/html/shop/images/cont_l_d_s.jpg';
	}else{
		document.getElementById('downHref').href='javascript:showDown();';
	//	document.getElementById('downImg').src='/templets/html/shop/images/cont_l_d.jpg';
	}
}

function gotoLogin(type)
{
					var cust_id = '{zlcms:articleField name="cust_id"/}';
					var goods_props = document.getElementById('attr_desc_para').value;
					var goods_id = '{zlcms:articleField name="info_id"/}';
					var goodsprice = document.getElementById('my_sale_price').value;
					//var stock_num =  {zlcms:articleField name="stock_num"/};
					var stock_num=document.getElementById("kc").innerText;
					var buy_num = document.getElementById('buy_num').value.replace(/(^\s*)|(\s*$)/g, '');
					if(buy_num =='')
					{
					  alert('请输入购买数量！');
					  return;
					}
					if(Number(buy_num) > Number(stock_num))
					{
					  alert('购买数量不能大于库存数！');
					  return;
					}
					var para = 'cust_id='+cust_id+'&goods_props='+goods_props+'&goods_id='+goods_id+'&goodsprice='+goodsprice+'&buy_num='+buy_num+'&type='+type;
					location.href='/shop_signin.html?'+window.location.href+'#'+para;
			
}

function gouwudisCheck()
{
	var s_user_id = document.getElementById('s_user_id').value;
	if(s_user_id==''){
		document.getElementById('gouwubefore').style.display = 'block';
		document.getElementById('gouwuafter').style.display = 'none';
	}else{
		document.getElementById('gouwuafter').style.display = 'block';
		document.getElementById('gouwubefore').style.display = 'none';
	}
}
function goumaidisCheck()
{
					var s_user_id = document.getElementById('s_user_id').value;
					
					if(s_user_id==''){
						document.getElementById('goumaibefore').style.display = 'block';
						document.getElementById('goumaiafter').style.display = 'none';
					}else{
						document.getElementById('goumaiafter').style.display = 'block';
						document.getElementById('goumaibefore').style.display = 'none';
					}
}
        /*
		function setGoodsImg(num){
			var ruleW=403,ruleH=546;
			var exp = document.getElementById('goodsimg'+num);
			if( !exp && typeof(exp)!="undefined" ){
			}else{
				var img_path = exp.src;
				$.ajax({
					type: 'POST',
					url: '/templets/html/jsp/getImgSize.jsp',
					data: 'img_path=' + img_path,
					success: function(msg){
						var imgArray = msg.split(',');
						var o_width = imgArray[0];
						var o_height = imgArray[1];
						var n_width = imgArray[2];
						var n_height = imgArray[3];
						var jscode = '';
						if(o_width*1 > n_width*1 && o_height*1 > n_height*1){
							jscode = 'onmouseover="qsoft.PopBigImage.create(this,20,0,30,5,true);"';
						}
						document.getElementById('goodsbigimgDiv').innerHTML='<img src="'+img_path+'" '+jscode+' id="biggimg"/>';
						if(n_width>=n_height){
							document.getElementById('biggimg').width = n_width;
						}else{
							document.getElementById('biggimg').height = n_height;
						}
						if(document.getElementById('biggimg').width > ruleW){
							document.getElementById('biggimg').width = ruleW;
						}
						if(document.getElementById('biggimg').height > ruleH){
							document.getElementById('biggimg').height = ruleH;
						}
					}
				});
			}
		}
*/

